//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Vml.Serialization;

namespace OpenLS.Vml
{
    internal class PowerpointTag : ShapeElement
    {
        private string name;
        private string type;
        private string value;
        internal const string xmlName = "tag";

        /// <summary>
        /// Generates an object from its XML representation
        /// </summary>
        /// <param name="context"></param>
        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read(VmlConstants.PowerpointNamespace +  xmlName))
            {
                //<p:tag name="CHARTTYPE" type="string" value="0"/>
                this.name = c.GetOptionalString("name");
                this.type = c.GetOptionalString("type");
                this.value = c.GetOptionalString("value");
            }
        }

        /// <summary>
        /// Convert an object into its XML representation
        /// </summary>
        /// <param name="context"></param>
        internal override void WriteXmlCore(WriteContext context)
        {
            using (var c = context.Write(VmlConstants.PowerpointNamespace + xmlName))
            {
                //<p:tag name="CHARTTYPE" type="string" value="0"/>
                c.SetOptionalString("name", name);
                c.SetOptionalString("type", type);
                c.SetOptionalString("value", value);
            }
        }
    }
}